package com.clps.digital.controller;

import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.ObjectUtil;
import com.clps.digital.common.BaseResponse;
import com.clps.digital.common.ErrorCode;
import com.clps.digital.common.ResultUtils;
import com.clps.digital.model.entity.Orders;
import com.clps.digital.service.OrderService;

import java.util.List;

/**
 * @Author: 小炎子
 * @Date: 2024/9/3 下午3:11
 * @Description: 订单控制类
 **/
public class OrderController {

    private OrderService orderService;

    /*
    * @Author 小炎子
    * @Description 获取当前用户所有的订单信息
    * @Date 下午3:13 2024/9/3
    */
    public BaseResponse<List<Orders>> getOdersList(){
        List<Orders> orderList = orderService.getOdersList();
        if (ObjUtil.isEmpty(orderList)) {
            return ResultUtils.error(ErrorCode.NOT_FOUND_ERROR,"无订单数据");
        }
        return ResultUtils.success(orderList);
    }

    public BaseResponse<List<Orders>> getAllOdersList(){
        List<Orders> orderList = orderService.getAllOrdersList();
        if (ObjectUtil.isEmpty(orderList)) {
            return ResultUtils.error(ErrorCode.NOT_FOUND_ERROR,"无订单数据");
        }
        return ResultUtils.success(orderList);
    }

}
